package com.corn.turorial.spring.exception;

import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;

import java.util.Collections;
import java.util.Map;
import java.util.NoSuchElementException;

/**
 * @author : Jim Wu
 * @version 1.0
 * @function :
 * @since : 2021/2/7 11:30
 */
@Slf4j
@ControllerAdvice
public class MyExceptionHandler2 {

    @ExceptionHandler(value = NoSuchElementException.class)
    public Map<String, Object> handlerArithmetic(Throwable e) {
        log.info("handlerArithmetic !");
        return Collections.singletonMap("msg", e.getMessage());
    }
}
